//1.下包并引入路由
import VueRouter from "vue-router";
import Vue from "vue";

const Home = () => import("@/pages/Home");
const Login = () => import("@/pages/Login");
const News = () => import("@/pages/Home/News");
const Music = () => import("@/pages/Home/Music");
const Game = () => import("@/pages/Home/Game");
const NotFound = () => import("@/pages/NotFound/404");
const MusicDetail =()=>import("@/pages/Home/Music/MusicDetail")
const NewsDetail =()=>import("@/pages/Home/News/NewsDetail")
Vue.use(VueRouter);


const router = new VueRouter({
  mode: "history",
  routes: [
    {
      path: "/",
      redirect: "/Home",
    },

    {
      path: "/Home",
      component: Home,
      //二级路由配置
      children: [
        {
  
          path: "News", 
          component: News,
          name: "News",
          children:[
            {
              path:"NewsDetail",
              component:NewsDetail,
              name:"NewsDetail"
            }
          ]
        },
        {
          path: "Music",
          component: Music,
          name: "Music",
          children:[
            {
              path:"MusicDetail/:id/:age?",
              component:MusicDetail,
              name:"MusicDetail",
            },
          ],
        },
        {
          path: "Game",
          component: Game,
          name: "Game",
        },
        {
          path: "",
          redirect: "News",
        },
      ],
    },
    {
      path: "/Login",
      component: Login,
      name: "Login",
    },

    //404配置卸载最下边
    {
      path: "/*",
      component: NotFound,
    },
  ],
});

//4.暴露router，注入到vue实例中
export default router;
